package com.rgs.ssm.dao;

import com.rgs.ssm.domain.Permission;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Ren Gaoshuai
 * @create 2021-05-29 9:23
 *
 * 权限 的持久层接口
 **/
public interface IPermissionDao {

    @Select("select * from permission where id in (select permissionId from role_permission where roleId = #{roleId})")
    List<Permission> findPermissionByRoleId(Integer roleId);

    @Insert("insert into permission (permissionName,url) values (#{permissionName},#{url})")
    void save(Permission permission);

    @Delete("delete from permission where id=#{id}")
    void delete(Integer id);

    @Update("update permission set permission=#{permission},url=#{url} where id=#{id}")
    void update(Permission permission);

    @Select("select * from permission")
    List<Permission> findAll();

    @Select("select * from permission where id=#{id}")
    Permission findById(Integer id);
}
